package com.coded2.mobileposto.model;

import java.math.BigDecimal;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;


/**
 * The persistent class for the modelo database table.
 * 
 */
@Entity
@NamedQuery(name="Modelo.findAll", query="SELECT m FROM Modelo m")
public class Modelo extends com.coded2.infra.comum.ComumDTO  {
	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	@Column(name="id_modelo")
	private int idModelo;

	@Column(name="no_modelo")
	private String noModelo;

	private BigDecimal potencia;

	//bi-directional many-to-one association to Consumo
	@OneToMany(mappedBy="modelo")
	private List<Consumo> consumos;

	//bi-directional many-to-one association to Fabricante
	@ManyToOne
	@JoinColumn(name="id_fabricante")
	private Fabricante fabricante;

	public Modelo() {
	}

	public int getIdModelo() {
		return this.idModelo;
	}

	public void setIdModelo(int idModelo) {
		this.idModelo = idModelo;
	}

	public String getNoModelo() {
		return this.noModelo;
	}

	public void setNoModelo(String noModelo) {
		this.noModelo = noModelo;
	}

	public BigDecimal getPotencia() {
		return this.potencia;
	}

	public void setPotencia(BigDecimal potencia) {
		this.potencia = potencia;
	}

	public List<Consumo> getConsumos() {
		return this.consumos;
	}

	public void setConsumos(List<Consumo> consumos) {
		this.consumos = consumos;
	}

	public Consumo addConsumo(Consumo consumo) {
		getConsumos().add(consumo);
		consumo.setModelo(this);

		return consumo;
	}

	public Consumo removeConsumo(Consumo consumo) {
		getConsumos().remove(consumo);
		consumo.setModelo(null);

		return consumo;
	}

	public Fabricante getFabricante() {
		return this.fabricante;
	}

	public void setFabricante(Fabricante fabricante) {
		this.fabricante = fabricante;
	}

	@Override
	public Object getId() {
		return getIdModelo();
}

}